# -*- coding:utf-8 -*-
# @FileName  :dhcc_ent_rule.py
# @Time      :2020/12/10 11:36
# @Author    :Zhoujirong
# @Desc      :企业异常查询阻断

from biz.flow.ent_rule import EntRuleRequest
from common.log import Log
from biz.cases.base_case import BaseCase


class TestEntRule(BaseCase):
    data_file_name = 'per_rule.yaml'
    @classmethod
    def setUpClass(cls):
        cls.cookie = BaseCase().get_token()
    def test_detail(self):
        '''异常查询阻断详情'''
        id = self.file_data.get('id')
        ret = EntRuleRequest.detail(id,self.cookie)
        Log.info(ret)
        self.assertEqual('1',ret.id)

    def test_a_update(self):
        '''异常查询阻断编辑'''
        comments = self.file_data.get('comments')
        controlMode = self.file_data.get('controlMode')
        deptCode = self.file_data.get('deptCode')
        ext1 = self.file_data.get('ext1')
        ext2 = self.file_data.get('ext2')
        ext3 = self.file_data.get('ext3')
        ext4 = self.file_data.get('ext4')
        ext5 = self.file_data.get('ext5')
        ext6 = self.file_data.get('ext6')
        id = self.file_data.get('id')
        interfaceControl = self.file_data.get('interfaceControl')
        lockUser = self.file_data.get('lockUser')
        pageControl = self.file_data.get('pageControl')
        resCode = self.file_data.get('resCode')
        resMsg = self.file_data.get('resMsg')
        ruleCode = self.file_data.get('ruleCode')
        ruleDescribe = self.file_data.get('ruleDescribe')
        ruleName = self.file_data.get('ruleName')
        ruleValue1 = self.file_data.get('ruleValue1')
        ruleValue2 = self.file_data.get('ruleValue2')
        ruleValue3 = self.file_data.get('ruleValue3')
        ruleValue4 = self.file_data.get('ruleValue4')
        serialNumber = self.file_data.get('serialNumber')
        stopFlag = self.file_data.get('stopFlag')
        ret = EntRuleRequest.update(comments,
                                    controlMode,
                                    deptCode,
                                    ext1,
                                    ext2,
                                    ext3,
                                    ext4,
                                    ext5,
                                    ext6,
                                    id,
                                    interfaceControl,
                                    lockUser,
                                    pageControl,
                                    resCode,
                                    resMsg,
                                    ruleCode,
                                    ruleDescribe,
                                    ruleName,
                                    ruleValue1,
                                    ruleValue2,
                                    ruleValue3,
                                    ruleValue4,
                                    serialNumber,
                                    stopFlag,self.cookie)
        self.assertEqual('00000000', ret.code)
        self.assertIn('操作成功', ret.msg)

    def test_b_get_page(self):
        '''异常查询阻断检索'''
        curPage = self.file_data.get('curPage')
        maxSize = self.file_data.get('maxSize')
        search_EQ_ruleCode = self.file_data.get('search_EQ_ruleCode')
        search_LIKE_ruleName = self.file_data.get('search_LIKE_ruleName')
        search_EQ_pageControl = self.file_data.get('search_EQ_pageControl')
        search_EQ_interfaceControl = self.file_data.get('search_EQ_interfaceControl')
        search_EQ_lockUser = self.file_data.get('search_EQ_lockUser')
        search_EQ_stopFlag = self.file_data.get('search_EQ_stopFlag')
        EQ_queryNum = self.file_data.get('EQ_queryNum')
        ret = EntRuleRequest.get_page(curPage,
                        maxSize,
                        search_EQ_ruleCode,
                        search_LIKE_ruleName,
                        search_EQ_pageControl,
                        search_EQ_interfaceControl,
                        search_EQ_lockUser,
                        search_EQ_stopFlag,
                        EQ_queryNum,self.cookie)
        Log.info(ret)
        self.assertEqual('1',ret.list[0].id)

    def test_c_open(self):
        '''异常查询阻断打开'''
        id = '1'
        stopFlag = 0
        ret = EntRuleRequest.start_stop(id,stopFlag,self.cookie)
        Log.info(ret)
        self.assertEqual('00000000', ret.code)
        self.assertIn('操作成功', ret.msg)

    def test_d_close(self):
        '''异常查询阻断关闭'''
        id = '1'
        stopFlag = 1
        ret = EntRuleRequest.start_stop(id, stopFlag, self.cookie)
        Log.info(ret)
        self.assertEqual('00000000', ret.code)
        self.assertIn('操作成功', ret.msg)








if __name__ == "__main__":
    pass